package com.jt.tenant.fragment;

import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.SpannableString;
import android.text.style.RelativeSizeSpan;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.amap.api.location.AMapLocation;
import com.jt.tenant.R;
import com.jt.tenant.action.LocationModular;
import com.jt.tenant.activity.AgreementActivity;
import com.jt.tenant.activity.BankListActivity;
import com.jt.tenant.activity.CarInfoActivity;
import com.jt.tenant.activity.ConductActivity;
import com.jt.tenant.activity.DataRechargeActivity;
import com.jt.tenant.activity.EquipSettingActivity;
import com.jt.tenant.activity.FreewayIntroduceActivity;
import com.jt.tenant.activity.FreewayServiceActivity;
import com.jt.tenant.activity.HomeInfoDetailActivity;
import com.jt.tenant.activity.InsCheckSelectActivity;
import com.jt.tenant.activity.InsClaimActivity;
import com.jt.tenant.activity.InsConfirmOrderActivity;
import com.jt.tenant.activity.InsInfoActivity;
import com.jt.tenant.activity.InsQuoteActivity;
import com.jt.tenant.activity.InsurerListActivity;
import com.jt.tenant.activity.IntegralActivity;
import com.jt.tenant.activity.IntegralRechargeActivity;
import com.jt.tenant.activity.MaintainActivity;
import com.jt.tenant.activity.NavigationAddressActivity;
import com.jt.tenant.activity.RefuelActivity;
import com.jt.tenant.activity.SpecialSaleActivity;
import com.jt.tenant.adapter.InformationAdapter;
import com.jt.tenant.app.JTApplication;
import com.jt.tenant.conn.GetHomeList;
import com.jt.tenant.conn.GetIndex;
import com.jt.tenant.conn.GetInformation;
import com.jt.tenant.conn.GetPIC;
import com.jt.tenant.conn.GetSpecialSale;
import com.jt.tenant.dialog.TipDialog;
import com.jt.tenant.dialog.TrackDialog;
import com.jt.tenant.widget.HomeBannerView;
import com.jt.tenant.widget.Tools;
import com.jt.tenant.widget.UpdateService;
import com.zcx.helper.activity.AppV4Fragment;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.Http;
import com.zcx.helper.pager.Carousel;
import com.zcx.helper.util.UtilApp;
import com.zcx.helper.util.UtilClear;
import com.zcx.helper.util.UtilToast;

import org.json.JSONException;
import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2016/2/1.
 */
public class HomeFragment extends AppV4Fragment implements View.OnClickListener {

    private GetHomeList.Info data = new GetHomeList.Info();

    private static List<String> picList_top = new ArrayList<>();

    private static List<String> picList_narrow = new ArrayList<>();

    private static List<String> picList = new ArrayList<>();

    private static List<GetPIC.PicList> picItemList_top = new ArrayList<>();

    private static List<GetPIC.PicList> picItemList_narrow = new ArrayList<>();

    private static List<GetPIC.PicList> picItemList = new ArrayList<>();

    private List<GetInformation.InfomationItem> infomationList = new ArrayList<>();

    private List<GetSpecialSale.SpecialSaleItem> specialSaleList = new ArrayList<>();

    private LinearLayout add_car;

    private TextView today_mlieage, today_time, gprs_surplus, gprs_recharge, today_oil, oil_refuel, today_integral, use_integral;//已绑定设备账号顶部数据

    private LinearLayout lin_home_1, lin_home_2, lin_home_3, lin_home_4, lin_home_5, lin_home_6, lin_home_7, lin_home_8;

    private ImageView iv_home_1, iv_home_2, iv_home_3, iv_home_4, iv_home_5, iv_home_6, iv_home_7, iv_home_8;

    private LinearLayout lin_banner_narrow;

    private ImageView iv_home_store_1, iv_home_store_2, iv_home_store_3;

    private HomeBannerView banner_top;

    private HomeBannerView banner_narrow;

    private LinearLayout lin_home_top;//顶部布局占位

    private View top_view;//顶部布局VIEW

    private ListView listView_info;

    private InformationAdapter informationAdapter;

    private Calendar calendar = Calendar.getInstance();

    public static RefreshLinstener refreshLinstener;

    public static OnDismiss onDismiss;

    private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    private TipDialog mDialog = null;

    private PackageInfo versionInfo = null;

    private String account_state;//账号状态   0：未添加车辆，未绑定设备  1：已添加车辆，未绑定设备  2：已绑定设备

    //更新相关变量

    public static UpdateSoftware updateSoftware;

    private int update_flag = 0;

    private Integer month, day;

    private String DownloadPath = "";

    private Context context = null;

    private LocationModular.OnLocateionChangeCallBack onLocateionChangeCallBack = new LocationModular.OnLocateionChangeCallBack() {

        @Override
        public void onLocation(AMapLocation aMapLocation) {

            JTApplication.lon = aMapLocation.getLongitude() + "";

            JTApplication.lat = aMapLocation.getLatitude() + "";

        }

    };

    private GetPIC getPIC_narrow = new GetPIC(new AsyCallBack<GetPIC.Info>() {

        @Override
        public void onSuccess(String toast, int type, GetPIC.Info info) throws Exception {

            super.onSuccess(toast, type, info);

            if (info.msg.equals("000")) {

                picItemList_narrow.clear();

                picList_narrow.clear();

                picItemList_narrow.addAll(info.picLists);

                for (int i = 0; i < info.picLists.size(); i++) {

                    picList_narrow.add(info.picLists.get(i).address);

                }

                banner_narrow.setItemList(picList_narrow);

            }

        }
    });

    private GetPIC getPIC_top = new GetPIC(new AsyCallBack<GetPIC.Info>() {

        @Override
        public void onSuccess(String toast, int type, GetPIC.Info info) throws Exception {

            super.onSuccess(toast, type, info);

            if (info.msg.equals("000")) {

                picItemList_top.clear();

                picList_top.clear();

                picItemList_top.addAll(info.picLists);

                for (int i = 0; i < info.picLists.size(); i++) {

                    picList_top.add(info.picLists.get(i).address);

                }

                banner_top.setItemList(picList_top);

            }

        }
    });

    private GetIndex getIndex = new GetIndex(new AsyCallBack<GetIndex.Info>() {

        @Override
        public void onStart(int type) throws Exception {

            Http.getInstance().show(getActivity());

        }

        @Override
        public void onSuccess(String toast, int type, GetIndex.Info info) throws Exception {

            if (info.msg.equals("000")) {

                JTApplication.jtPreferences.saveUserIntegral(info.integralCount, "1");

                JTApplication.jtPreferences.saveUserIntegral(info.commonCount, "2");

                JTApplication.jtPreferences.saveInsFlag(info.baoxianFlag);

                JTApplication.jtPreferences.saveScore(info.score);

                DownloadPath = info.downloadPath;

                if (info.egsFlag == null || info.egsFlag.equals("null")) {

                    JTApplication.jtPreferences.saveFreeway("0");

                } else {

                    JTApplication.jtPreferences.saveFreeway(info.egsFlag);

                }

//                if (Integer.parseInt(info.version.replace(".", "")) > Integer.parseInt(versionInfo.versionName.replace(".", ""))) {
//
//                    update_flag = 1;
//
//                    mDialog = new TipDialog(getActivity());
//
//                    mDialog.setTip("优路兔已更新到" + info.version + "版本,是否立即更新？");
//
//                    mDialog.setType(9);
//
//                    mDialog.show();
//
//                }


            } else {

                UtilToast.show(getActivity(), info.msg);

            }

        }

        @Override
        public void onFail(String toast, int type) throws Exception {

            super.onFail(toast, type);

//            Toast.makeText(getActivity(), "获取信息失败", Toast.LENGTH_SHORT).show();

        }

        @Override
        public void onEnd(String toast, int type) throws Exception {

        }

    });

    private GetHomeList getHomeList = new GetHomeList(new AsyCallBack<GetHomeList.Info>() {

        @Override
        public void onSuccess(String toast, int type, GetHomeList.Info info) throws Exception {


            if (info.msg.equals("000")) {

                data.homeLists.clear();

                data.homeLists.addAll(info.homeLists);

                data.totaltime = info.totaltime;

                data.totalmileage = info.totalmileage;

                data.averagespeed = info.averagespeed;

                data.today_fuel = info.today_fuel;

                data.surplusGprs = info.surplusGprs;

                data.score = info.score;

                today_mlieage.setText(Tools.F_num(info.totalmileage));

                today_time.setText("用时" + info.totaltime.replace(":", "小时") + "分钟");

                gprs_surplus.setText(Tools.F_num(info.surplusGprs));

                today_oil.setText(Tools.F_num(String.valueOf(Float.parseFloat(info.today_fuel) / 1000)));

                Log.e("TY", JTApplication.jtPreferences.readUserIntegral("1"));

                Log.e("DX", JTApplication.jtPreferences.readUserIntegral("2"));

                today_integral.setText(Tools.F_num(String.valueOf(Float.parseFloat(JTApplication.jtPreferences.readUserIntegral("1")) + Float.parseFloat(JTApplication.jtPreferences.readUserIntegral("2")))));

                if (MeFragment.refreshLinster != null) {

                    MeFragment.refreshLinster.refresh();

                }

            }

        }

        @Override
        public void onEnd(String toast, int type) throws Exception {

            Http.getInstance().dismiss();

        }

    });

    //获取实时信息
    private GetInformation getInformation = new GetInformation(new AsyCallBack<GetInformation.Info>() {

        @Override
        public void onSuccess(String toast, int type, GetInformation.Info info) throws Exception {

            super.onSuccess(toast, type, info);

            if (info.msg.equals("000")) {

                infomationList.clear();

                infomationList.addAll(info.InformationList);

                informationAdapter.notifyDataSetChanged();

            }
        }
    });

    private GetSpecialSale getSpecialSale = new GetSpecialSale(new AsyCallBack<GetSpecialSale.Info>() {

        @Override
        public void onSuccess(String toast, int type, GetSpecialSale.Info info) throws Exception {

            super.onSuccess(toast, type, info);

            specialSaleList.clear();

            specialSaleList.addAll(info.specialSaleList);

            JTApplication.UtilAsyncBitmap.get(info.specialSaleList.get(0).pic, iv_home_store_1, R.mipmap.loading);

            JTApplication.UtilAsyncBitmap.get(info.specialSaleList.get(1).pic, iv_home_store_2, R.mipmap.loading);

            JTApplication.UtilAsyncBitmap.get(info.specialSaleList.get(2).pic, iv_home_store_3, R.mipmap.loading);

        }
    });

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable final Bundle savedInstanceState) {

        context = getActivity();

        account_state = JTApplication.jtPreferences.readAccountState();

        getIndex.lon = JTApplication.lon;

        getIndex.lat = JTApplication.lat;

        getIndex.execute(context);

        PackageManager manager;

        manager = getActivity().getPackageManager();

        try {

            versionInfo = manager.getPackageInfo(getActivity().getPackageName(), 0);

            Log.e("aaaaaaaaaa", versionInfo.versionName);

        } catch (PackageManager.NameNotFoundException e) {

// TODO Auto-generated catch block

            e.printStackTrace();

        }

        updateSoftware = new UpdateSoftware() {
            @Override
            public void update() {

                if (!DownloadPath.equals("") && update_flag == 1) {

                    //更新版本
                    Intent intent = new Intent(getActivity(), UpdateService.class);

                    intent.putExtra("file_real_name", UtilApp.appName(getActivity()) + ".apk");

                    intent.putExtra("title", UtilApp.appName(getActivity()));

                    intent.putExtra("DownloadPath", DownloadPath);

                    getActivity().startService(intent);

                    UtilToast.show(getActivity(), "正在后台下载，稍后会自动安装");

                    mDialog.dismiss();

                }

            }

        };

        calendar = Calendar.getInstance();

        month = calendar.get(Calendar.MONTH) + 1;

        day = calendar.get(Calendar.DAY_OF_MONTH);

        if (month == 12 && 24 <= day && day <= 26) {


        }

        View view = JTApplication.ScaleScreenHelper.loadView((ViewGroup) inflater.inflate(R.layout.fragment_home, null));

        getPIC_narrow.type = "0";

        getPIC_narrow.execute(getContext());

        lin_home_top = (LinearLayout) view.findViewById(R.id.lin_home_top);

        addTop();

        (lin_home_1 = (LinearLayout) view.findViewById(R.id.lin_home_1)).setOnClickListener(this);

        (lin_home_2 = (LinearLayout) view.findViewById(R.id.lin_home_2)).setOnClickListener(this);

        (lin_home_3 = (LinearLayout) view.findViewById(R.id.lin_home_3)).setOnClickListener(this);

        (lin_home_4 = (LinearLayout) view.findViewById(R.id.lin_home_4)).setOnClickListener(this);

        (lin_home_5 = (LinearLayout) view.findViewById(R.id.lin_home_5)).setOnClickListener(this);

        (lin_home_6 = (LinearLayout) view.findViewById(R.id.lin_home_6)).setOnClickListener(this);

        (lin_home_7 = (LinearLayout) view.findViewById(R.id.lin_home_7)).setOnClickListener(this);

        (lin_home_8 = (LinearLayout) view.findViewById(R.id.lin_home_8)).setOnClickListener(this);

        iv_home_1 = (ImageView) view.findViewById(R.id.iv_home_1);

        iv_home_2 = (ImageView) view.findViewById(R.id.iv_home_2);

        iv_home_3 = (ImageView) view.findViewById(R.id.iv_home_3);

        iv_home_4 = (ImageView) view.findViewById(R.id.iv_home_4);

        iv_home_5 = (ImageView) view.findViewById(R.id.iv_home_5);

        iv_home_6 = (ImageView) view.findViewById(R.id.iv_home_6);

        iv_home_7 = (ImageView) view.findViewById(R.id.iv_home_7);

        iv_home_8 = (ImageView) view.findViewById(R.id.iv_home_8);

        if (!account_state.equals("2")) {

            iv_home_5.setImageResource(R.mipmap.icon_home_freeway_off);

            iv_home_6.setImageResource(R.mipmap.icon_home_journey_off);

        }

        lin_banner_narrow = (LinearLayout)view.findViewById(R.id.lin_home_banner_narrow);

        banner_narrow = (HomeBannerView) view.findViewById(R.id.banner_home_narrow);

        if(account_state.equals("1")){

            lin_banner_narrow.setVisibility(View.GONE);

        }

        (iv_home_store_1 = (ImageView) view.findViewById(R.id.iv_home_store_1)).setOnClickListener(this);

        (iv_home_store_2 = (ImageView) view.findViewById(R.id.iv_home_store_2)).setOnClickListener(this);

        (iv_home_store_3 = (ImageView) view.findViewById(R.id.iv_home_store_3)).setOnClickListener(this);

        getSpecialSale.execute(context);

        listView_info = (ListView) view.findViewById(R.id.lv_home_rtinfo);

        informationAdapter = new InformationAdapter(context, infomationList);

        listView_info.setAdapter(informationAdapter);

        listView_info.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

                Bundle mbundle = new Bundle();

                mbundle.putString("type", infomationList.get(position).type);

                mbundle.putString("name", infomationList.get(position).title);

                mbundle.putString("time", infomationList.get(position).time);

                mbundle.putString("detail", infomationList.get(position).detail);

                Intent intent = new Intent(context, HomeInfoDetailActivity.class);

                intent.putExtras(mbundle);

                startActivity(intent);

            }
        });

        getInformation.execute(context);

//        banner_narrow.setOnCarouselItemListener(new Carousel.OnCarouselItemListener<String>() {
//            @Override
//            public void onCarouselItemClick(String s) throws Exception {
//
//                super.onCarouselItemClick(s);
//
//                for (int i = 0; i < picItemList_narrow.size(); i++) {
//
//                    if (s.equals(picItemList_narrow.get(i).address)) {
//
//                        try {
//
//                            BannerNext(picItemList_narrow.get(i).type, picItemList_narrow.get(i).url);
//
//                        } catch (ClassNotFoundException e) {
//
//                            e.printStackTrace();
//
//                        }
//
//                    }
//
//                }
//
//            }
//        });


        refreshLinstener = new RefreshLinstener() {

            @Override
            public void refresh() {

                getIndex.execute(context);

                getInformation.execute(context);

                addTop();

            }

        };


        return view;

    }

    private void addTop() {

        lin_home_top.removeAllViews();

//        account_state = "1";

        if (account_state.equals("0")) {

            top_view = View.inflate(context, R.layout.home_top_addcar, null);

            JTApplication.ScaleScreenHelper.loadView((ViewGroup) top_view);

            lin_home_top.addView(top_view);

            (add_car = (LinearLayout) top_view.findViewById(R.id.lin_home_addcar)).setOnClickListener(this);

        } else if (account_state.equals("1")) {

            top_view = View.inflate(context, R.layout.home_top_noobd, null);

            JTApplication.ScaleScreenHelper.loadView((ViewGroup) top_view);

            lin_home_top.addView(top_view);

            banner_top = (HomeBannerView) top_view.findViewById(R.id.banner_home_top);

            getPIC_top.type = "1";

            getPIC_top.execute(context);

            picItemList_top.clear();

            picList_top.clear();

            picItemList_top.addAll(picItemList);

            picList_top.addAll(picList);

            banner_top.setItemList(picList_top);

        } else if (account_state.equals("2")) {

            top_view = View.inflate(context, R.layout.home_top_haveobd, null);

            JTApplication.ScaleScreenHelper.loadView((ViewGroup) top_view);

            lin_home_top.addView(top_view);

            //today_mlieage,today_time,gprs_surplus,gprs_recharge,today_oil,oil_refuel,today_integral,use_integral

            today_mlieage = (TextView) top_view.findViewById(R.id.tv_home_mileage);

            today_time = (TextView) top_view.findViewById(R.id.tv_home_time);

            gprs_surplus = (TextView) top_view.findViewById(R.id.tv_home_data);

            (gprs_recharge = (TextView) top_view.findViewById(R.id.tv_home_gprs_recharge)).setOnClickListener(this);

            today_oil = (TextView) top_view.findViewById(R.id.tv_home_petrol);

            (oil_refuel = (TextView) top_view.findViewById(R.id.tv_home_refuel)).setOnClickListener(this);

            today_integral = (TextView) top_view.findViewById(R.id.tv_home_integral);

            (use_integral = (TextView) top_view.findViewById(R.id.tv_home_use_integral)).setOnClickListener(this);

            getHomeList.execute(context);

        }

    }


    @Override
    public void onClick(View v) {

        switch (v.getId()) {

            case R.id.lin_home_addcar:

                Intent intent_edit_car = new Intent(context, CarInfoActivity.class);

                startActivity(intent_edit_car);

                break;

            case R.id.lin_home_1:

                Intent intent_insurance = null;

                if(JTApplication.jtPreferences.readInsFlag().equals("2")){

                    intent_insurance = new Intent(context, InsQuoteActivity.class);

                }else if(JTApplication.jtPreferences.readInsFlag().equals("1")){

                    intent_insurance = new Intent(context, InsCheckSelectActivity.class);

                }else {

//                 intent_insurance = new Intent(context, InsInfoActivity.class);

                    intent_insurance = new Intent(context, InsurerListActivity.class);

//                 intent_insurance = new Intent(context, InsQuoteActivity.class);

//                 intent_insurance = new Intent(context, InsConfirmOrderActivity.class);

                }

                startActivity(intent_insurance);

                break;

            case R.id.lin_home_2:

                Intent intent_maintain = new Intent(context, MaintainActivity.class);

                startActivity(intent_maintain);

                break;

            case R.id.lin_home_3:

//                Intent intent_conduct = new Intent(context, ConductActivity.class);

//                Intent intent_conduct = new Intent(context, BankListActivity.class);

                Intent intent_refuel = new Intent(context,RefuelActivity.class);

                startActivity(intent_refuel);


                break;

            case R.id.lin_home_4:

                Intent intent_conduct = new Intent(context, BankListActivity.class);

//                Intent intent_equip = new Intent(context, EquipSettingActivity.class);

                startActivity(intent_conduct);


                break;

            case R.id.lin_home_5:

                if (JTApplication.jtPreferences.readAccountState().equals("2")&&!JTApplication.jtPreferences.readFreeway().equals("0")) {

                    Intent intent_freeway;

                    Log.e("FREEWAY=======",JTApplication.jtPreferences.readFreeway());

                    if(JTApplication.jtPreferences.readFreeway().equals("2")) {

                        intent_freeway = new Intent(context, FreewayIntroduceActivity.class);

                    }else {

                        intent_freeway = new Intent(context, FreewayServiceActivity.class);

                    }

                    startActivity(intent_freeway);

                } else {

                    if(JTApplication.jtPreferences.readFreeway().equals("0")){

                        TipDialog tipDialog = new TipDialog(getActivity());

                        tipDialog.setTip("您已提交审核申请，请勿重复提交。");

                        tipDialog.setType(0);

                        tipDialog.show();

                    }else {

                        UtilToast.show(context, "该功能需要绑定OBD设备");

                    }

                }

                break;

            case R.id.lin_home_6:

                if (JTApplication.jtPreferences.readAccountState().equals("2")) {

                    new TrackDialog(getActivity()).show();

                } else {

                    UtilToast.show(context, "该功能需要绑定OBD设备");

                }

                break;

            case R.id.lin_home_7:

                Intent intent_navi = new Intent(context, NavigationAddressActivity.class);

                startActivity(intent_navi);

                break;

            case R.id.lin_home_8:

                Intent intent_integral = new Intent(context, IntegralActivity.class);

                startActivity(intent_integral);

                break;

            case R.id.iv_home_store_1:

                startActivity(new Intent(context, InsurerListActivity.class));

//                startActivity(new Intent(context, SpecialSaleActivity.class)
//
//                        .putExtra("id", specialSaleList.get(0).id)
//
//                );

                break;

            case R.id.iv_home_store_2:

//                TipDialog tipDialog = new TipDialog(context);
//
//                tipDialog.setType(0);
//
//                tipDialog.setTip("保险专场暂未开通");
//
//                tipDialog.show();

                startActivity(new Intent(context, MaintainActivity.class));

//                startActivity(new Intent(context, SpecialSaleActivity.class)
//
//                        .putExtra("id",specialSaleList.get(1).id)
//
//                );

                break;

            case R.id.iv_home_store_3:

                TipDialog tipDialog1 = new TipDialog(context);

                tipDialog1.setType(0);

                tipDialog1.setTip("其它服务暂未开通");

                tipDialog1.show();

//                startActivity(new Intent(context, InsClaimActivity.class));
//
//                        .putExtra("id",specialSaleList.get(2).id)
//
//                );

                break;

            case R.id.tv_home_refuel:

                startActivity(new Intent(getActivity(), RefuelActivity.class));

                break;

            case R.id.tv_home_gprs_recharge:

                startActivity(new Intent(getActivity(), DataRechargeActivity.class));

                break;

            case R.id.tv_home_use_integral:

                startActivity(new Intent(getActivity(), IntegralRechargeActivity.class));

                break;


        }

    }

    @Override
    public void onResume() {

        super.onResume();

        JTApplication.locationModular.addOnLocateionChangeCallBack(onLocateionChangeCallBack);

    }


    @Override
    public void onStop() {

        super.onStop();

        JTApplication.locationModular.removeOnLocateionChangeCallBack(onLocateionChangeCallBack);

    }

    @Override
    public void onDestroy() {

        super.onDestroy();

        onDismiss = null;

        refreshLinstener = null;

        UtilClear.clear(getView());

    }

    public abstract class RefreshLinstener {

        public abstract void refresh();

    }

    private void BannerNext(String type, String value) throws ClassNotFoundException {

        switch (type) {
//            0:转跳activity，1：转跳网页，2：无操作

            case "0":

                startActivity(new Intent(getActivity(), Class.forName(value)));

                break;

            case "1":

                startActivity(new Intent(getActivity(), AgreementActivity.class)
                        .putExtra("title", "简途科技")
                        .putExtra("id", "0")
                        .putExtra("url", value));

                break;

            case "2":

                break;


        }


    }

    public abstract class UpdateSoftware {

        public abstract void update();

    }

    public abstract class OnDismiss {

        public abstract boolean onDismiss();

    }

}
